//
//  MessageDetailViewController.m
//  TestSchool
//
//  Created by 吴 晓泉 on 12-11-8.
//  Copyright (c) 2012年 yaoxia. All rights reserved.
//

#import "MessageDetailViewController.h"
#import "UserManager.h"

@interface MessageDetailViewController ()

@end

@implementation MessageDetailViewController

@synthesize nameLabel,timeLabel,contentView,message;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"Detail";
    
    if ([[UserManager getCurrentUser].name isEqualToString:[self.message objectForKey:@"to"]]) {
        self.nameLabel.text = @"Teacher:";
    }
    else
    {
        self.nameLabel.text = @"Me:";
    }
    
    NSString *timeIntervalStr = [self.message objectForKey:@"dtime"];
    
//    //实例化一个NSDateFormatter对象
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//    //设定时间格式,这里可以设置成自己需要的格式
//    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    //用[NSDate date]可以获取系统当前时间
//    NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[timeIntervalStr longLongValue]/1000]];
//    //输出格式为：2010-10-27 10:22:13
//    self.timeLabel.text = currentDateStr;
    
    self.timeLabel.text = timeIntervalStr;
    self.contentView.text = [self.message objectForKey:@"content"];
    [self addRoundBound:self.contentView];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.nameLabel = nil;
    self.timeLabel = nil;
    self.contentView = nil;
    self.message = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
